﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;

namespace YJKStairs.CommonUnit
{
	public static class StairsRunParamManager
	{
		public static double GetActualRisersHeight(StairsRun run)
		{
			double result = 0.0;
			if (run != null)
			{
				Stairs stairs = run.GetStairs();
				if (stairs != null)
				{
					result = StairsParamManager.GetActualRisersHeight(stairs);
				}
			}
			return result;
		}

		public static double GetStairsRunRefHeight(StairsRun run)
		{
			double result = 0.0;
			if (run != null)
			{
				Stairs stairs = run.GetStairs();
				if (stairs != null)
				{
					result = stairs.BaseElevation;
				}
			}
			return result;
		}

		public static double GetTreadThickness(StairsRun run)
		{
			double result = 0.0;
			if (run != null)
			{
				Stairs stairs = run.GetStairs();
				if (stairs != null)
				{
					result = StairsParamManager.GetTreadThickness(stairs);
				}
			}
			return result;
		}

		public static double GetAbsoluteBaseElevation(StairsRun run)
		{
			double result = 0.0;
			if (run != null)
			{
				result = run.BaseElevation + StairsRunParamManager.GetStairsRunRefHeight(run);
			}
			return result;
		}

		public static double GetAbsoluteTopElevation(StairsRun run)
		{
			double result = 0.0;
			if (run != null)
			{
				result = run.TopElevation + StairsRunParamManager.GetStairsRunRefHeight(run);
			}
			return result;
		}

		public static double GetRunProjectCycleLength(StairsRun run)
		{
			double result = 0.0;
			if (run.IsValidObject)
			{
				CurveLoop footprintBoundary = run.GetFootprintBoundary();
				if (footprintBoundary != null)
				{
					result = footprintBoundary.GetExactLength();
				}
			}
			return result;
		}
	}
}
